package com.gxa.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author zxd
 * @date 2025/6/13
 */
@RestController
@Tag(name = "智能对话", description = "智能对话相关接口")
public class ChatController {

    @Autowired
    private ChatClient chatClient;

    @GetMapping("/chat/v2")
    @Operation(summary = "deepseek聊天流式调用")
    public Flux<String> chat2( String msg,String chatId) {
        Flux<String> stream = chatClient.prompt().user(msg)
                .advisors(a->a.param(ChatMemory.CONVERSATION_ID, chatId))
                .stream().content();
        return stream;
    }

}